package com.ofood.domain;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.ofood.utils.DateTimeUtils;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author jack
 * @food menu
 */
public class Food implements Serializable {
    /**
     * food id
     */
    private Integer id;

    /**
     * food name
     */
    private String foodName;

    /**
     * food avatar
     */
    private String foodAvatar;

    /**
     * food attachment,administrator can upload food attachment
     */
    private String foodAttachment;

    /**
     * food description
     */
    private String foodDescription;

    /**
     * food price
     */
    private BigDecimal foodPrice;

    /**
     * food manufacturing date
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime foodMfg;

    /**
     * food expiry date
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime foodExp;

    /**
     * food created date
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime foodCreated;

    /**
     * food update date
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime foodUpdated;

    /**
     * food exp date string
     */
    private String foodExpStr;

    /**
     * food mfg date string
     */
    private String foodMfgStr;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getFoodName() {
        return foodName;
    }

    public void setFoodName(String foodName) {
        this.foodName = foodName;
    }

    public String getFoodAvatar() {
        return foodAvatar;
    }

    public void setFoodAvatar(String foodAvatar) {
        this.foodAvatar = foodAvatar;
    }

    public String getFoodAttachment() {
        return foodAttachment;
    }

    public void setFoodAttachment(String foodAttachment) {
        this.foodAttachment = foodAttachment;
    }

    public String getFoodDescription() {
        return foodDescription;
    }

    public void setFoodDescription(String foodDescription) {
        this.foodDescription = foodDescription;
    }

    public BigDecimal getFoodPrice() {
        return foodPrice;
    }

    public void setFoodPrice(BigDecimal foodPrice) {
        this.foodPrice = foodPrice;
    }

    public LocalDateTime getFoodMfg() {
        return foodMfg;
    }

    public void setFoodMfg(LocalDateTime foodMfg) {
        this.foodMfg = foodMfg;
    }

    public LocalDateTime getFoodExp() {
        return foodExp;
    }

    public void setFoodExp(LocalDateTime foodExp) {
        this.foodExp = foodExp;
    }

    public LocalDateTime getFoodCreated() {
        return foodCreated;
    }

    public void setFoodCreated(LocalDateTime foodCreated) {
        this.foodCreated = foodCreated;
    }

    public LocalDateTime getFoodUpdated() {
        return foodUpdated;
    }

    public void setFoodUpdated(LocalDateTime foodUpdated) {
        this.foodUpdated = foodUpdated;
    }

    public String getFoodExpStr() {
        return DateTimeUtils.convertLocalTimeToString(foodExp);
    }

    public void setFoodExpStr(String foodExpStr) {
        this.foodExpStr = foodExpStr;
    }

    public String getFoodMfgStr() {
        return DateTimeUtils.convertLocalTimeToString(foodMfg);
    }

    public void setFoodMfgStr(String foodMfgStr) {
        this.foodMfgStr = foodMfgStr;
    }

    public Food(){
        super();
    }

    public Food(String foodName){
        this.foodName=foodName;
    }

    @Override
    public String toString() {
        return "Food{" +
                "foodName='" + foodName + '\'' +
                '}';
    }
}
